package cn.tedu.boot10.controller;

import cn.tedu.boot10.entity.Student;
import cn.tedu.boot10.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController

@RequestMapping("/student")
public class StudentController {
    @Autowired
    StudentMapper mapper;

    @RequestMapping("/select")
    public List<Student> select() {
        System.out.println(mapper.select());
        return mapper.select();
    }

    @RequestMapping("/deleteById")
    public void deleteById(int id) {
        mapper.deleteById(id);
    }

    @RequestMapping("/insert")
    public void insert(@RequestBody Student student) {
        mapper.insert(student);
    }

    @RequestMapping("/selectByCid")
    public List<Student> selectByCid(int id) {
        return mapper.selectByCid(id);
    }
}
